package com.example.rootwar.search;

import java.util.ArrayList;
import java.util.List;

public class day1206 {


    public static boolean canConstruct(String ransomNote, String magazine) {


        char[] chars = ransomNote.toCharArray();

        char[] chars1 = magazine.toCharArray();

       List<Integer> objects = new ArrayList<>();


        for (char aChar : chars) {
            boolean is=false;

            for (int i = 0; i < chars1.length; i++) {
                char c = chars1[i];
                if (c==aChar&&!objects.contains(i)){
                    is=true;
                    objects.add(i);
                    break;
                }
            }


            if (!is){
                return false;
            }

        }
        return true;

    }


    public static String truncateSentence(String s, int k) {

        char[] chars = s.toCharArray();


        StringBuffer stringBuffer = new StringBuffer();

        int count=0;
        int i=0;

        for (int j = 1; j <=k ; j++) {
            while (i<chars.length&&chars[i]!=' '){
                stringBuffer.append(chars[i]);
                i++;
            }
            count++;
            if (count!=k){
                stringBuffer.append(chars[i]);
            }
            i++;
        }

        return stringBuffer.toString();

    }


    public static void main(String[] args) {

//    String a="aa";
//    String b="ab";
//
//
//        boolean b1 = canConstruct(a, b);
//        System.out.println(b1);

        System.out.println();

    }
}
